<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<script src="{{url_for('static',filename='js/jquery.js')}}"></script>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<head>
    <meta charset="UTF-8">
    <title>用户中心</title>
    <style>
        .tbl_style {
            text-align: center;
        }

        .user_a a {
            text-decoration: none;
        }

        .tbl_style td a {
            text-decoration: none;
        }

        .search p {
            color: #5b5353;

        }

        .list_style th {
            /*表头文字居中*/
            text-align: center;
        }

    </style>
</head>

<h1>用户中心</h1>
<p class="user_a">
    <a href="{{url_for('user.register')}}">注册</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="{{url_for('user.login')}}">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
<body>
<!--上传附件-->

<form action="{{url_for('user.form')}}" method="post" enctype="multipart/form-data">
    <p><input type="file" name="file"></p>
    <p><input type="submit" required value="上传"/></p>
</form>
<div>
    <form class="search" action="{{url_for('user.user_center')}}" method="get">
        <p>{{msg}}</p>
        <table style="width: 50%" cellspacing="0" border="1px">
            <p>
                <input type="text" name="search" placeholder="请输入姓名手机号邮箱或创建时间"/>&nbsp;&nbsp;
                <input type="button" value="搜索" id="search"/>&nbsp;&nbsp;
                <input type="reset" value="重置" id="reset"/>
            </p>
            <tr class="list_style">
                <th>序号</th>
                <th>用户名</th>
                <th>电话</th>
                <th>邮箱</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            {% for u in user %}
            <tr class="tbl_style">
                <td>{{loop.index}}</td>
                <td>{{u.username}}</td>
                <td>{{u.phone}}</td>
                {% if not u.emial: %}
                <td>{{''}}</td>
                {% else %}
                <td>{{u.emial}}</td>
                {% endif %}
                <td>{{u.createTime}}</td>
                <td><a href="{{url_for('user.update')}}?id={{u.id}}">更新</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="{{url_for('user.delete')}}?id={{u.id}}">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            {% endfor %}

        </table>
        <!--分页功能-->

    </form>
</div>


</body>
<script>
    <!--    禁止在a 标签中点击-->
    $("#click").attr("disable", true).css("pointer-events", "none")
    $("#search").click(function () {
        let content = $('input[name="search"]').val();
        location.href = '{{url_for("user.search")}}?search=' + content
    });
    $("#reset").click(function () {
        // let redirect = $('input[name="reset"]').val();
        location.href = '{{url_for("user.user_center")}}'
    });
    $("#download").click(function () {
        let filename = document.getElementById('download').innerHTML;

        location.href = '{{url_for("user.download_file")}}?filename=' + filename
    })
</script>
</html>